Merged
Conversation
+ Access the value of the ancestors
+ Applies a MemoryOptimizedJsonMapper()
There was a problem hiding this comment.
Pull Request Overview
This pull request introduces ancestor tracking functionality to the JsonMapper class to enable class mapping decisions based on parent and ancestor JSON objects, addressing issue cweiske#212. It also provides memory optimization strategies for handling deeply nested structures.
- Refactored JsonMapper to support ancestor tracking through all mapping operations
- Added MemoryOptimizedJsonMapper class with configurable depth limiting and field filtering
- Comprehensive test coverage for ancestor-aware mapping and memory optimizations
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/JsonMapper.php | Core implementation of ancestor tracking through mapWithAncestors method and updated getMappedType signature |
| src/MemoryOptimizedJsonMapper.php | New class extending JsonMapper with memory optimization features for ancestor tracking |
| tests/ClassMapAncestorsTest.php | Test cases verifying ancestor-aware class mapping and backward compatibility |
| tests/MemoryOptimizedJsonMapperTest.php | Comprehensive test suite for memory optimization features |
| tests/support/*.php | Support classes (Contract, ContractBody, ContractVote, etc.) for testing ancestor functionality |
| usage_example.php | Practical usage examples demonstrating memory optimization strategies |
| memory_analysis.php | Analysis script showing memory impact and optimization benefits |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces ancestor tracking to the
JsonMapperclass, allowing mapping decisions to be made based on parent and ancestor JSON objects. It also provides memory optimization strategies for handling deeply nested structures, and adds comprehensive tests to ensure correct behavior and backward compatibility.Ancestor tracking and mapping enhancements:
JsonMapperto support passing an array of ancestor JSON objects through all mapping operations, enabling class mapping decisions based on parent and ancestor data. This includes changes tomap,mapWithAncestors,mapArray, andgetMappedType, as well as updating all internal calls to propagate the ancestor chain. [1] [2] [3] [4] [5] [6] [7] [8] [9]Memory optimization:
MemoryOptimizedJsonMapperclass that limits ancestor tracking depth and/or filters ancestor fields to reduce memory usage in deeply nested JSON scenarios. This class provides configurable options and a method to retrieve memory usage statistics.Testing and documentation:
ClassMapAncestorsTestto verify correct ancestor-aware class mapping, deep ancestor access, and backward compatibility with older classMap functions.memory_analysis.phpto demonstrate the memory impact of ancestor tracking and showcase optimization strategies.Contract.